@echo off
pushd %0\..

echo #######################################################
echo #
echo # SpringProx API - building Windows libraries
echo #
echo #######################################################
echo.

set OLD_PATH=%PATH%
if not exist v:\dev\builder\win32_i386\setenv.cmd goto :NO_SETENV
call v:\dev\builder\win32_i386\setenv.cmd
set PATH=v:\dev\builder\Tools;%SystemRoot%\system32;%PATH%

set SOURCE_DIR=i:\projects\common
if not exist %SOURCE_DIR%\* goto :NO_SOURCE
set OBJECT_DIR=.\obj
set TARGET_DIR=..\..\runimage\win32_x86

echo # Creating directories
echo.

mkdir %OBJECT_DIR% > NUL:
mkdir %TARGET_DIR% > NUL:
mkdir %TARGET_DIR%\unicode > NUL:
mkdir %TARGET_DIR%\stdcall > NUL:

echo.
echo # Invoking make
echo.
make
if errorlevel 1 goto :FAILED
echo.
echo # Done
echo.
goto :END

:NO_SETENV
echo.
echo # ERROR - Toolchain's SETENV.CMD not found
echo #         Please edit build.cmd and define the correct installation
echo #         path of your toolchain
echo.
goto :END

:NO_SOURCE
echo.
echo # ERROR - Source directory doesn't existe or is empty
echo #         Please edit build.cmd and define the correct path where
echo #         your source tree is located
echo.
goto :END

:FAILED
echo.
echo # ERROR - Make failed
echo.

:END
pause